<?php

/**
* get how many selected drops
*
*/
$dropTimes = sizeof($_POST["dropBox"]);

//usrDebug("dropTimes",$dropTimes);

/**
* Reupdate me please since
* This code already built by MenuAccelerator
*
*/
//list all records name
$lstArray = array("trDateEnt",
                  "dueDateEnt",
                  "whoseEnt",
                  "currencyEnt",
                  "rateEnt",
                  "cbSource",
                  "remainEnt",
                  "paymentEnt",
                  "amountEnt");


//shift it for many times
foreach($lstArray as $list){

  for($i = $dropTimes ; $i > 0 ; $i--){

    /**
    * Since $_POST["dropBox"] index is using array numbering
    * then we need to reduce the droppoint by 1.
    * E.g: $dropTimes = 3 => $_POST["dropBox"][3] will result Error
    *      since the dropTimes is trying to point to 3rd element
    *      of $_POST["dropBox"], which array wise is at [2] meaning 3rd element
    *
    */
    $dropPoint = $_POST["dropBox"][($i-1)];

    if(empty($_POST[$list])){

      /* Do nothing, in order to suppress error msg */
    }else{

      /**
      * slice it! so we could have the buffer's tail
      *
      */
      $bufTail   = @array_slice($_POST[$list], $dropPoint);

      //var_dump($bufTail);

      //replace it
      @array_splice($_POST[$list],                /* The original array or dummy */
                    ($dropPoint - ARRAY_NUMBER),  /* Calculate the cursor, since it comes with array numbering */
                    sizeof($bufTail),             /* The sizeof array concat with */
                    $bufTail);                    /* The array we concat with */

      //var_dump($_POST[$list]);
    }
  }
}
unset($list);

$newNum = $_SESSION["init_sub"] - $dropTimes;

if($newNum >= 0){

  $_SESSION["init_sub"] = $newNum;
}else{

  $_SESSION["init_sub"] = 0;
}

/**
 * some portion of this code
 * have been moved to procDrop.php.bak
 * to revert kindly check the file out
 */
?>